<template>
  <div class="myDiv">
    <!-- 现役军人家属 -->
    <el-card class="box-card secordCard" shadow="never">
      <div slot="header" class="clearfix">
        <span>现役军人家属信息</span>
        <!-- <el-button style="float: right; padding: 3px 0" type="text">收起</el-button> -->
      </div>
      <div>
        <el-form :model="form" ref="form" :rules="rules" :inline="true" class="formWidth" label-width="170px">
          <el-row :gutter="10">
            <el-col :span="8">
              <el-form-item label="与现役军人关系" prop="relation">
                <el-select v-model="form.relation" placeholder="请选择与现役军人关系">
                  <el-option
                    v-for="dict in relationOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="是否随军" prop="isArmy">
                <el-select v-model="form.isArmy" placeholder="请选择是否随军">
                  <el-option
                    v-for="dict in isArmyOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="现就业状况" prop="employmentSituation">
                <el-select v-model="form.employmentSituation" placeholder="请选择现就业状况">
                  <el-option
                    v-for="dict in employmentSituationOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
             <el-form-item label="现役军人姓名" prop="soldierName">
              <el-input v-model="form.soldierName" placeholder="请输入现役军人姓名" />
            </el-form-item>
            </el-col>
            <el-col :span="8">
               <el-form-item label="现役军人性别" prop="soldierSex">
                <el-select v-model="form.soldierSex" placeholder="请选择现役军人性别">
                  <el-option
                    v-for="dict in soldierSexOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="现役军人职级" prop="soldierLevel">
                <el-select v-model="form.soldierLevel" placeholder="请选择现役军人职级">
                  <el-option
                    v-for="dict in soldierLevelOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="现役军人身份证号" prop="soldierIdCard">
                <el-input v-model="form.soldierIdCard" placeholder="请输入现役军人身份证号" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="现役军队证件号" prop="soldierCertificate">
                <el-input v-model="form.soldierCertificate" placeholder="请输入现役军队证件号" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="现役军人入伍时间" prop="soldierEnlistedDate">
                <el-date-picker clearable size="small"
                  v-model="form.soldierEnlistedDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择现役军人入伍时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "activeCard",
  data(){
    return {
      // 与现役军人关系字典
      relationOptions: [],
      // 是否随军字典
      isArmyOptions: [],
      // 现就业状况字典
      employmentSituationOptions: [],
      // 现役军人性别字典
      soldierSexOptions: [],
      // 现役军人职级字典
      soldierLevelOptions: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        relation: [
          { required: true, message: "与现役军人关系不能为空", trigger: "change" }
        ],
        isArmy: [
          { required: true, message: "是否随军不能为空", trigger: "change" }
        ],
        employmentSituation: [
          { required: true, message: "现就业状况不能为空", trigger: "change" }
        ],
      }
    }
  },
  props:{
    soldierId: String,
  },
  mounted(){
    this.form.soldierId = this.soldierId
  },
  created() {
    this.getDicts("relation").then(response => {
      this.relationOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isArmyOptions = response.data;
    });
    this.getDicts("employment_situation").then(response => {
      this.employmentSituationOptions = response.data;
    });
    this.getDicts("s_sex").then(response => {
      this.soldierSexOptions = response.data;
    });
    this.getDicts("soldier_level").then(response => {
      this.soldierLevelOptions = response.data;
    });
  },
  methods:{
    validateForm(){
      return new Promise((resolve , reject) => {
        this.$refs.form.validate(valid => {
          if (valid) {
            resolve();
          } else reject();
        });
      })
    }
  },
}
</script>
<style lang="scss" scoped>
.box-card{
  margin-bottom: 16px;
}
::v-deep .secordCard .el-form-item__content {
   height: 36px;
}
</style>